home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / test / lib / memory.c < prev    next >
C/C++ Source or Header  |  1992-11-23  |  986b  |  45 lines

  1.  
  2. /*
  3.  *  MEMORY.C
  4.  *
  5.  *  test movmem, cmpmem, setmem/clrmem
  6.  */
  7.  
  8. static unsigned char Buf[1024];
  9.  
  10. main()
  11. {
  12.     short i;
  13.     unsigned char *buf = (unsigned char *)(((long)Buf + 3) & ~3);
  14.  
  15.     for (i = 0; i < 256; ++i) {
  16.     buf[3] = 'x';
  17.     buf[4+i] = 'x';
  18.     setmem(buf + 4, i, i);
  19.     if (buf[3] != 'x' || buf[4+i] != 'x')
  20.         puts("setmem failed");
  21.     if (i && (buf[4] != (i & 255) || buf[4+i-1] != (i & 255)))
  22.         puts("setmem failed");
  23.     }
  24.     strcpy(buf, "abcdefgh");
  25.     movmem(buf, buf + 1, 4);
  26.     if (strcmp(buf, "aabcdfgh"))
  27.     puts("movmem failed 1");
  28.     strcpy(buf, "abcdefgh");
  29.     movmem(buf+1,buf, 4);
  30.     if (strcmp(buf, "bcdeefgh"))
  31.     puts("movmem failed 2");
  32.     strcpy(buf, "abcdefgh");
  33.     strcpy(buf+512+251, "ijklmnop");
  34.     buf[511] = 23;
  35.     movmem(buf+4, buf+512, 255);
  36.     if (strcmp(buf+512+255, "mnop"))
  37.     puts("movmem failed 3");
  38.     if (strcmp(buf+512, "efgh"))
  39.     puts("movmem failed 4");
  40.     if (buf[511] != 23)
  41.     puts("movmem failed 5");
  42.     puts("test complete");
  43. }
  44.  
  45.